home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / base-de.h < prev    next >
C/C++ Source or Header  |  1996-03-03  |  3KB  |  121 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_base_de_h)
  24. #define octave_base_de_h 1
  25.  
  26. #include "dColVector.h"
  27. #include "dMatrix.h"
  28.  
  29. class
  30. base_diff_eqn
  31. {
  32. public:
  33.  
  34.   base_diff_eqn (void) : x (), t (0.0) { }
  35.  
  36.   base_diff_eqn (const ColumnVector& xx, double tt) : x (xx), t (tt) { }
  37.  
  38.   base_diff_eqn (const base_diff_eqn& a) : x (a.x), t (a.t) { }
  39.  
  40.   virtual ~base_diff_eqn (void) { }
  41.  
  42.   base_diff_eqn& operator = (const base_diff_eqn& a)
  43.     {
  44.       if (this != &a)
  45.     {
  46.       x = a.x;
  47.       t = a.t;
  48.     }
  49.       return *this;
  50.     }
  51.  
  52.   // Derived classes must provide functions to actually do the
  53.   // integration.
  54.  
  55.   // Return the vector of states at output time t.
  56.   virtual ColumnVector do_integrate (double t) = 0;
  57.  
  58.   // Return a matrix of states at each output time specified by t.
  59.   // The rows of the result matrix should each correspond to a new
  60.   // output time.
  61.   virtual Matrix do_integrate (const ColumnVector& t) = 0;
  62.  
  63.   // There must also be a way for us to force the integration to
  64.   // restart.
  65.   virtual void force_restart (void) = 0;
  66.  
  67.   // Lots of ways to call the single function and optionally set and
  68.   // get additional information.
  69.  
  70.   // Integrate to t from current point.
  71.   virtual ColumnVector integrate (double t)
  72.     { return do_integrate (t); }
  73.  
  74.   // Set new x0, t0 and integrate to t.
  75.   virtual ColumnVector integrate (const ColumnVector& x0, double t0, double t)
  76.     {
  77.       initialize (x0, t0);
  78.       return do_integrate (t);
  79.     }
  80.  
  81.   // Integrate from current point and return output at all points
  82.   // specified by t.
  83.   virtual Matrix integrate (const ColumnVector t)
  84.     { return do_integrate (t); }
  85.  
  86.   // Set new x0, t0 and integrate to return output at all points
  87.   // specified by t.
  88.   virtual Matrix integrate (const ColumnVector& x0, double t0,
  89.                 const ColumnVector t)
  90.     {
  91.       initialize (x0, t0);
  92.       return do_integrate (t);
  93.     }
  94.  
  95.   virtual void initialize (const ColumnVector& x0, double t0)
  96.     {
  97.       x = x0;
  98.       t = t0;
  99.       force_restart ();
  100.     }
  101.  
  102.   int size (void) const { return x.capacity (); }
  103.  
  104.   ColumnVector state (void) const { return x; }
  105.  
  106.   double time (void) const { return t; }
  107.  
  108. protected:
  109.  
  110.   ColumnVector x;
  111.   double t;
  112. };
  113.  
  114. #endif
  115.  
  116. /*
  117. ;;; Local Variables: ***
  118. ;;; mode: C++ ***
  119. ;;; End: ***
  120. */
  121.